package com.test.dao;

import com.test.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper {
    // 注解结尾不能有分号
    @Select("select * from user")
    List<User> getUsers();

    // 多个参数使用方式 (@Param("id") int id,@Param("name") String name)
    // 参数名称和@Param("")里面的名称对应
    @Select("select * from user where id=#{id}")
    User getUserById(@Param("id") int id);

    @Insert("insert into user (name,pwd) values(#{name},#{pwd})")
    int addUser(User user);

    @Delete("delete from user where id=#{id}")
    int delUser(@Param("id") int id);

    @Update("update user set name=#{name},pwd=#{pwd} where id=#{id}")
    int upUser(@Param("name") String name,@Param("pwd") String pwd,@Param("id") int id);
}
